<script setup>
import { useCountDown } from '@/composables/useCountDown'
import { useShopCart } from '@/stores/shopCart'

const shopCart = useShopCart()
const { start, formateTime } = useCountDown()
// 倒计时时间，不可以大于一小时
start(60 * 30)

const handleClick = () => {
  shopCart.clearcheckoutCart()
}
</script>

<template>
  <div class="xtx-pay-page">
    <div class="container">
      <!-- 付款信息 -->
      <div class="pay-info">
        <span class="iconfont icon-queren2"></span>
        <div class="tip">
          <p>订单提交成功！请尽快完成支付。</p>
          <p>
            支付还剩 <span>{{ formateTime }}</span
            >, 超时后将取消订单
          </p>
        </div>
        <div class="amount">
          <span>应付总额：</span>
          <!-- Math.floor(shopCart.totalCheckPrice / 50)运费 -->
          <span>¥{{ shopCart.totalCheckPrice + Math.floor(shopCart.totalCheckPrice / 50) }}</span>
        </div>
      </div>
      <!-- 付款方式 -->
      <div class="pay-type">
        <p class="head">选择以下支付方式付款</p>
        <div class="item">
          <p>支付平台</p>
          <router-link
            class="btn wx"
            href="javascript:;"
            :to="{
              path: '/payback',
              query: {
                method: '微信支付',
                price: shopCart.totalCheckPrice + Math.floor(shopCart.totalCheckPrice / 50)
              }
            }"
            @click.prevent="handleClick"
            ><i class="iconfont icon-weixinzhifu"></i>微信支付</router-link
          >

          <router-link
            class="btn alipay iconfont icon-zhifubaozhifu"
            :to="{
              path: '/payback',
              query: {
                method: '支付宝',
                price: shopCart.totalCheckPrice + Math.floor(shopCart.totalCheckPrice / 50)
              }
            }"
            @click="handleClick"
          ></router-link>
        </div>
        <div class="item">
          <p>支付方式</p>
          <a class="btn active" href="javascript:;">招商银行</a>
          <a class="btn" href="javascript:;">工商银行</a>
          <a class="btn" href="javascript:;">建设银行</a>
          <a class="btn" href="javascript:;">农业银行</a>
          <a class="btn" href="javascript:;">交通银行</a>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.xtx-pay-page {
  height: 800px;
  .pay-info {
    height: 200px;
    margin: 20px 0;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;

    > span {
      color: $xtxColor;
      font-size: 75px;
      padding-left: 80px;
    }
    .tip {
      p:nth-child(1) {
        font-size: 20px;
      }
    }
    .amount {
      padding-left: 550px;
      flex: 1;
      span:nth-child(2) {
        font-size: 18px;
        line-height: 1;
        position: relative;
        top: -1px; /* 根据视觉效果微调 */
        vertical-align: middle;
        color: $helpColor;
      }
    }
  }
  .pay-type {
    display: flow-root;
    height: 500px;
    background-color: #fff;
    .head {
      margin: 15px 20px;
      font-size: 15px;
    }
    .item {
      p {
        padding: 20px;
        font-size: 15px;
      }
      .btn {
        width: 150px;
        height: 50px;
        border: 1px solid #e4e4e4;
        text-align: center;
        line-height: 48px;
        margin-left: 30px;
        color: #666;

        display: inline-flex; // 关键：flex布局
        align-items: center; // 垂直居中
        justify-content: center; // 水平居中
        &.active,
        &:hover {
          border-color: $xtxColor;
        }
      }
      .wx {
        font-size: 15px;

        i {
          vertical-align: middle;
          color: #1aad19;
          font-size: 30px;
          margin-right: 5px;
        }
      }
      .alipay {
        color: #1677ff;
        font-size: 30px;
      }
    }
  }
}
</style>
